



var data=JSON.parse(sessionStorage.getItem("key"));

console.log("0",data);

// data=["杀手","水民","杀手","水民","水民","水民","杀手","杀手","杀手","水民","杀手","水民","杀手","水民","水民","水民","杀手","杀手"];
// console.log("1",data);

// check = document.getElementsByTagName("button")[0];//获取按钮的节点







//返回按钮发牌页面

function backspace() {
    window.open("../task3/task3-1.html")

}




//关闭会到主页面

var off = document.getElementById("off");
// 关闭按钮返回到主页面
off.onclick = function () {
    // 点击关闭弹出提示窗口
    if (confirm("是 否 (退出游戏回到主页面)")) {
        location.href = "../task2/task2-1.html"; //点击确定返回到主页面
    } else {
        return false; //点击取消停留在当前页面
    }
};





for (var i=0; i+1<data.length;i++){
       var A="\n";
       var main=`<div class="profession-box">
${A}<div class="profession-flex">
${A}<div class="profession-name">${data[i]}</div>
${A}<div class="profession-num">${i+2}号</div>
${A}</div>${A}</div>`;

    $(main).appendTo("#main-box");  //根据数组长度，复制盒子
    }

function playerObj() {
    var player=[];
    for (let i=0; i < data.length;i++){
        player.push({name:data[i],num:(i+1),class:"label",cause:"none",
            deathDay:""});
    }
    sessionStorage.setItem('playerState',JSON.stringify(player));
    sessionStorage.setItem('begin','start');

}
playerObj();
var click = document.getElementById("button");
click.onclick = function () {
    location.href = "../task4/task4-1.html";
    console.log(click);
};




